﻿namespace Torrenter.Common.Objects
{
    public class SingleEpTorrentSearch : ITorrentSearch
    {
        public string SearchString 
        { 
            get
            {
                return EpisodeDefinition.ShowName + " " + EpisodeDefinition.SeasonString + EpisodeDefinition.EpisodeString;
            }
        }

        public bool isMatch(string Name)
        {
            var trig = Name.Replace(" ", "").Replace(".","").ToLower();// Name.Trim(' ', '.');
            if (trig.StartsWith(EpisodeDefinition.ShowName.Replace(" ","").ToLower()) &&
                 Name.ToLower().Contains(EpisodeDefinition.SeasonString + EpisodeDefinition.EpisodeString)
                )
            {
                return true;
            }
            return false;
            
            
        }

        public EpisodeDefinition  EpisodeDefinition{ get; set; }

        public Torrent Torrent { get; set; }

        public SingleEpTorrentSearch(Torrent torrent)
        {
            EpisodeDefinition = torrent.EpisodeDefinition;
            Torrent = torrent;
        }

        public override string ToString()
        {
            return SearchString;
        }


        
    }
}
